﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BTCairo
{
    public class Line : Shape
    {
        int x1, y1, x2, y2;
        BasicShape line;
        public Line(CommonGraphics _comGra, int _x1, int _y1, int _x2, int _y2)
        {
            myCommonGraphic = _comGra;
            x1 = _x1;
            y1 = _y1;
            x2 = _x2;
            y2 = _y2;
            
        }
        public override InfoGraphic getInfoShape()
        {
            InfoGraphic info = myCommonGraphic.MyInfoGraphic;
            info.x = Math.Min(x1, x2);
            info.y = Math.Min(y1, y2);
            info.widthShape = Math.Abs(x1 - x2);
            info.heightShape = Math.Abs(y1 - y2);
            return info;
        }
        public override Shape CloneShape()
        {
            Line temp = new Line(myCommonGraphic.CloneCommonGraphic(), x1, y1, x2, y2);
            return temp;
        }
        public override Shape CloneShape(int plusX, int plusY)
        {
            Line temp = new Line(myCommonGraphic.CloneCommonGraphic(), x1+plusX, y1+plusY, x2+plusX, y2+plusY);
            return temp;
        }
        public override void Draw()
        {
            if (shadow != null)
                shadow.DoEffect(this);
            if (highlight != null)
                highlight.DoEffect(this);
            if (border != null)
                border.DoEffect(this);
            line = new BasicLine(myCommonGraphic, x1, y1, x2, y2);
            line.Draw();
        }
        public override void DrawEffect()
        {
            line = new BasicLine(myCommonGraphic, x1, y1, x2, y2);
            line.Draw();  
        }

        //public override string ToString()
        //{
        //    return line.ToString();
        //}

        public override void ParseXmlElement(System.Xml.XmlDocument doc, System.Xml.XmlElement root)
        {
            if (shadow != null)
                shadow.ParseXmlElement(doc, root);
            if (highlight != null)
                highlight.ParseXmlElement(doc, root);
            if (border != null)
                border.ParseXmlElement(doc, root);
            line.ParseXmlElement(doc, root);
        }
    }
}
